package com.ruoyi.work.query;

import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Calendar;
import java.util.Date;

@Getter@Setter
public class ProductQuery extends QueryObject {
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date beginTime;
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date endTime;

    //查询的时间是00点到00点 所以需要 +1天-1秒
    public Date getEndTime() {
        if(endTime==null){
            return null;
        }
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(endTime);
        //加一天
        calendar.add(Calendar.DAY_OF_YEAR,1);
        //减1秒
        calendar.add(Calendar.SECOND,-1);
        return calendar.getTime();
    }
}
